home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr28 / mxmnu239.zip / NOVTRANS.MNU < prev    next >
Text File  |  1993-03-22  |  14KB  |  415 lines

  1. Comment
  2. ========================================================================
  3.  
  4. Novell menu to MarxMenu Translator:
  5.  
  6. Copyright 1989-92 by Marc Perkel * All rights reserved.
  7.  
  8. Usage: MARXMENU NOVTRANS <novell menu>
  9.  
  10. This program was written to translate Novell menus to MarxMenus. It is
  11. not an exact translation, but does the bulk of the work. It is up to you
  12. to edit the output file and tune the menu the way you want.
  13.  
  14. I have made no attempt to copy color information. I am not presenting
  15. selections in sorted order, but in the order in which they are defined.
  16.  
  17. The program creates a MarxMenu file names <menu>.TMP where <menu> is the
  18. name of your Novell menu file. Then it compiles <menu>.TMP into
  19. <menu>.MRX file that should be ready to run. if the menu needs to be
  20. altered, you will have to rename the <menu>.TMP file to a MNU file and
  21. then you can work with it like any other MarxMenu source file.
  22.  
  23. ========================================================================
  24. EndComment
  25.  
  26. Var
  27.    Menus MenuPtr CommandPtr LinePtr ThisMenu ThisChoice
  28.    BoxDim VarNum PromptLine Out Cap InputAVar NovellFileName
  29.    MarxMenuFileName NovellTempFileName Greek Titles NovLines
  30.  
  31. ;----- Translator Messages
  32.  
  33. Const
  34.    TopMessage = "Joe Blow's Master Menu"
  35.    BottomMessage = "*-<< Acme Manufacturing Company >>-*"
  36.  
  37. ;----- If you want the Greek Column effect, set to true
  38.  
  39. Greek = False
  40.  
  41. Qualifier MenuName MenuTitle YPos XPos MenuColor MenuChoices
  42. Qualifier ChoiceName ChoiceCmd
  43.  
  44. Comment
  45. ========================================================================
  46.  
  47. This is the main body of the NovTrans Program.
  48.  
  49. ========================================================================
  50. EndComment
  51.  
  52. if not NetWorkVersion
  53.    ClearScreen
  54.    Writeln
  55.    Writeln 'This translator requires the network version of MarxMenu to Run!'
  56. endif
  57.  
  58. PreAmble
  59. PrepareFiles
  60. Header
  61. Parse
  62. WriteOutMenus
  63. Footer
  64.  
  65. ClearScreenFirst Off
  66. Writeln
  67. Execute 'MARXCOMP.EXE ' + MarxMenuFileName
  68.  
  69. Writeln
  70. Writeln 'To test your menu type MARX ' NovellFileName '. When you are satisfied with'
  71. Writeln 'the translation, replace the Novell ' NovellFileName '.MNU file'
  72. Writeln 'with the ' MarxMenuFileName ' file that NovTrans just created.'
  73.  
  74. Comment
  75. =====================================
  76.  
  77. Subroutine area.
  78.  
  79. =====================================
  80. EndComment
  81.  
  82. ;----- Initilize Variables and Environment
  83.  
  84. Procedure PreAmble
  85.    ClearScreenOnExit Off
  86.    StandardIO
  87.    Writeln
  88.    NovellFileName = UpperCase(ParamStr(2))
  89.    Usage
  90. EndProc
  91.  
  92. ;----- Proper Usage Procedure
  93.  
  94. Procedure Usage
  95.    if NovellFileName = ''
  96.       Writeln('Usage: MarxMenu NovTrans <menu>')
  97.       Writeln('Converts Novell menus to MarxMenus.')
  98.       Writeln('Be sure to backup your original menus before running!!')
  99.       ExitMenu
  100.    endif
  101. EndProc
  102.  
  103. ;----- Create FileNames and open Files
  104.  
  105. Procedure PrepareFiles
  106.    if pos('.',NovellFileName) > 0
  107.       NovellFileName = left(NovellFileName,pred(pos('.',NovellFileName)))
  108.    endif
  109.  
  110.    NovellTempFileName = NovellFileName + '.MNU'
  111.    MarxMenuFileName = ForceExtension(NovellTempFileName,'TMP')
  112.  
  113.    ReadTextFile(NovellTempFileName,NovLines)
  114.    Writeln 'Creating ' MarxMenuFileName
  115.  
  116.    FileAssign(Out,MarxMenuFileName)
  117.    FileCreate(Out)
  118. EndProc
  119.  
  120.  
  121. Procedure BlankLine
  122.    FileWriteln(Out,'')
  123. EndProc
  124.  
  125. ;----- Write out the MarxMenu Source Header
  126.  
  127. Procedure Header
  128.   BlankLine
  129.   FileWriteln(Out,'Comment')
  130.   FileWriteln(Out,'==========================================================')
  131.   BlankLine
  132.   FileWriteln(Out,'This File was converted from Novell Menu: ',NovellTempFileName)
  133.   BlankLine
  134.   FileWriteln(Out,'It should behave in a similar way to the original menu but')
  135.   FileWriteln(Out,'not necessarilly exactly the same. It will be close enough')
  136.   FileWriteln(Out,'for you to fine tune it the way you want.')
  137.   BlankLine
  138.   FileWriteln(Out,'To add a choice to a menu simply use the AddChoice command')
  139.   FileWriteln(Out,'then add the appropiate Onkey statement.')
  140.   FileWriteln(Out,'The menu will make the size adjustments accordinaly.')
  141.   BlankLine
  142.   FileWriteln(Out,'  Example:')
  143.   FileWriteln(Out,'      AddChoice("Print Console",10)')
  144.   FileWriteln(Out,'      ... ')
  145.   FileWriteln(Out,'      ... ')
  146.   FileWriteln(Out,'      OnKey Task(10)')
  147.   FileWriteln(Out,'        cd \public')
  148.   FileWriteln(Out,'        PConsole')
  149.   FileWriteln(Out,'      ...')
  150.   BlankLine
  151.   FileWriteln(Out,"If you want to change the menu's center, pass the XY")
  152.   FileWriteln(Out,"coordinates to menu's CenterStretchBox procedure.")
  153.   BlankLine
  154.   FileWriteln(Out,'   Example:')
  155.   FileWriteln(Out,'      CenterStretchBox("Menu Header",40,12)')
  156.   BlankLine
  157.   FileWriteln(Out,'This will cause the menu to center at Col 40, Row 12')
  158.   BlankLine
  159.   FileWriteln(Out,'Instead of defining the center of the box, there is a command')
  160.   FileWriteln(Out,'CornerStretchBox where the box grows down and right.')
  161.   BlankLine
  162.   FileWriteln(Out,'   Example:')
  163.   FileWriteln(Out,'      CornerStretchBox("Menu Header",8,6)')
  164.   BlankLine
  165.   FileWriteln(Out,'Once you are satisfied with the translation you can copy the TMP file')
  166.   FileWriteln(Out,'over the old Novell MNU file and just work with the MarxMenu version.')
  167.   BlankLine
  168.   FileWriteln(Out,'To control custom features, edit CUSTOM.INC and other INCLUDE Files.')
  169.   BlankLine
  170.   FileWriteln(Out,'=========================================================')
  171.   FileWriteln(Out,'EndComment')
  172.   BlankLine
  173.   FileWriteln(Out,';----- Create Variables')
  174.   BlankLine
  175.   FileWriteln(Out,'var')
  176.   FileWriteln(Out,'  %NovVar1')
  177.   FileWriteln(Out,'  %NovVar2')
  178.   FileWriteln(Out,'  %NovVar3')
  179.   FileWriteln(Out,'  %NovVar4')
  180.   FileWriteln(Out,'  %NovVar5')
  181.   FileWriteln(Out,'  %NovVar6')
  182.   FileWriteln(Out,'  %NovVar7')
  183.   FileWriteln(Out,'  %NovVar8')
  184.   FileWriteln(Out,'  %NovVar9')
  185.   FileWriteln(Out,'  %NovVar10')
  186.   FileWriteln(Out,'  KeepUsersInMenu')
  187.   BlankLine
  188.   BlankLine
  189.   FileWriteln(Out,';----- Here is where you add you own menu title and status line message')
  190.   BlankLine
  191.   FileWriteln(Out,'MenuTitle      = "',TopMessage,'"')
  192.   FileWriteln(Out,'StatusLineText = "',BottomMessage,'"')
  193.   BlankLine
  194.   FileWriteln(Out,';----- Load Novell look and feel routines')
  195.   BlankLine
  196.   FileWriteln(Out,'Include "CUSTOM.INC"')
  197.   if Greek then FileWriteln(Out,'Greek = True')
  198.   BlankLine
  199.   FileWriteln(Out,'KeepUsersInMenu Off  ;Change to On to keep users in menu.')
  200.   BlankLine
  201.   FileWriteln(Out,'Comment')
  202.   FileWriteln(Out,'=================================')
  203.   BlankLine
  204.   FileWriteln(Out,'MarxMenu is capable of software metering. This means that it can')
  205.   FileWriteln(Out,'limit the number of users of an application to a fixed amount.')
  206.   BlankLine
  207.   FileWriteln(Out,'  OnKey Task (2)')
  208.   FileWriteln(Out,"     |if Limit('LOTUS',6) then Return ;limit Lotus to 6 Users")
  209.   FileWriteln(Out,'     CD \PUBLIC\LOTUS')
  210.   FileWriteln(Out,'     123')
  211.   BlankLine
  212.   FileWriteln(Out,'Read the METER.INC file for more details.')
  213.   BlankLine
  214.   FileWriteln(Out,'=================================')
  215.   FileWriteln(Out,'EndComment')
  216.   BlankLine
  217.   FileWriteln(Out,"Include 'METER.INC'  ;Software Metering")
  218.   BlankLine
  219.   FileWriteln(Out,'Comment')
  220.   FileWriteln(Out,'=================================')
  221.   BlankLine
  222.   FileWriteln(Out,'In order to add menu choices conditionally you would append the')
  223.   FileWriteln(Out,'choices to the end of the array after all the default choices')
  224.   FileWriteln(Out,'are set. For Example:')
  225.   BlankLine
  226.   FileWriteln(Out,'   if InGroup("ACCOUNTING")')
  227.   FileWriteln(Out,'      AddChoice("Payroll Menu",10)')
  228.   FileWriteln(Out,'   endif')
  229.   BlankLine
  230.   FileWriteln(Out,'Here is where menus are created.')
  231.   BlankLine
  232.   FileWriteln(Out,'=================================')
  233.   FileWriteln(Out,'EndComment')
  234.   BlankLine
  235.   FileFlush(Out);
  236. EndProc
  237.  
  238.  
  239. ;----- Write out the MarxMenu Source Footer
  240.  
  241. Procedure Footer
  242.    BlankLine
  243.    FileWriteln(Out,';----- End of Menu')
  244.    FileClose(Out)
  245. EndProc
  246.  
  247. ;----- Preprocess Lines
  248.  
  249. Procedure Parse
  250. Var ChoicePtr TotalLines X St St2
  251.    TotalLines = NumberOfElements(NovLines)
  252.    Writeln('Parsing Novell Menu source code ...')
  253.    MenuPtr = 0
  254.    loop(TotalLines)
  255.       if (LoopIndex Mod 10 = 0) or (LoopIndex = TotalLines)
  256.          Write Cr
  257.          Write('Processing Line # ',LoopIndex,' of ',TotalLines)
  258.       endif
  259.       if left(NovLines[LoopIndex],1) = '%'
  260.          ChoicePtr = 0
  261.          CommandPtr = 0
  262.          MenuPtr = MenuPtr + 1
  263.          Actual ThisMenu = Loc Menus[MenuPtr]
  264.          St = mid(NovLines[LoopIndex],2,255)
  265.          X = pos(',',St)
  266.          if X = 0 then X = succ(Length(St))
  267.          ThisMenu.MenuTitle = left(St,X - 1)
  268.          Trim(ThisMenu.MenuTitle)
  269.          AppendArray(Titles,UpperCase(ThisMenu.MenuTitle))
  270.          delete(St,1,X)
  271.          St2 = '       '
  272.          if MenuPtr < 10 then St2 = St2 + ' '
  273.          ThisMenu.MenuName = 'Menu' + Str(MenuPtr) + St2 + '{' + ThisMenu.MenuTitle + '}'
  274.          ThisMenu.YPos = value(NextWord(St))
  275.          ThisMenu.XPos = value(NextWord(St))
  276.          ThisMenu.MenuColor = value(NextWord(St))
  277.       else
  278.          if left(NovLines[LoopIndex],1) > ' '
  279.             CommandPtr = 0
  280.             ChoicePtr = ChoicePtr + 1
  281.             Trim(NovLines[LoopIndex])
  282.             if Mid(NovLines[LoopIndex], 2, 1) = '.'
  283.                Delete(NovLines[LoopIndex],1,2)
  284.                Trim(NovLines[LoopIndex])
  285.             endif
  286.  
  287.             ;----- Get rid of multiple spaces
  288.  
  289.             while pos('  ',NovLines[LoopIndex]) > 0
  290.                delete(NovLines[LoopIndex],pos('  ',NovLines[LoopIndex]),1)
  291.             endwhile
  292.  
  293.             ;----- Get rid of double quotes
  294.  
  295.             while pos('"',NovLines[LoopIndex]) > 0
  296.                delete(NovLines[LoopIndex],pos('"',NovLines[LoopIndex]),1)
  297.             endwhile
  298.  
  299.             ThisMenu.MenuChoices[ChoicePtr].ChoiceName = NovLines[LoopIndex]
  300.          else
  301.             if NovLines[LoopIndex] > ''
  302.                if ChoicePtr = 0
  303.                   Writeln
  304.                   Writeln 'Error in menu line: ' LoopIndex
  305.                   ExitMenu
  306.                endif
  307.                CommandPtr = CommandPtr + 1
  308.                ThisMenu.MenuChoices[ChoicePtr].ChoiceCmd[CommandPtr] = NovLines[LoopIndex]
  309.             endif
  310.          endif
  311.       endif
  312.    endloop
  313. EndProc
  314.  
  315. ;----- Create the Menu Choices Array
  316.  
  317. Procedure WriteOutMenuChoices
  318.    Writeln
  319.    Write('Translating: ' + ThisMenu.MenuName + ' ... ')
  320.    BlankLine
  321.    FileWriteln(Out,';----- Translating: ' + ThisMenu.MenuTitle)
  322.    BlankLine
  323.    if MenuPtr > 1
  324.       FileWriteln(Out,':',ThisMenu.MenuName)
  325.       BlankLine
  326.    endif
  327.    loop ThisMenu.MenuChoices
  328.       FileWriteln(Out,'  AddChoice("' + ThisMenu.MenuChoices[LoopIndex].ChoiceName + '",' + Str(LoopIndex) + ')')
  329.    endloop
  330.    BlankLine
  331.    FileWriteln(Out,'CenterStretchBox("' + ThisMenu.MenuTitle + '",' + Str(ThisMenu.XPos) + ',' + Str(ThisMenu.YPos) + ')')
  332.    BlankLine
  333. EndProc
  334.  
  335. ;----- Create the Onkey Statements
  336.  
  337. Procedure WriteOutOnkeyChoices
  338. var Tmp St X Y Z
  339.    loop ThisMenu.MenuChoices
  340.       Actual ThisChoice = Loc ThisMenu.MenuChoices[LoopIndex]
  341.       Tmp = ThisChoice.ChoiceName
  342.       FileWriteln(Out,'OnKey Task(' + Str(LoopIndex) + ')')
  343.       loop ThisChoice.ChoiceCmd
  344.          CommandPtr = LoopIndex
  345.          Tmp = ThisChoice.ChoiceCmd[CommandPtr]
  346.          Trim(Tmp)
  347.          if UpperCase(Tmp) = '!LOGOUT' then Tmp = '|Logoff'
  348.          if Left(Tmp,1) = '%'
  349.             delete(Tmp,1,1)
  350.             X = PosInList(UpperCase(Tmp),Titles)
  351.             if X = 0
  352.                Writeln
  353.                Writeln 'Error: Menu ' Tmp ' not Found!'
  354.                ExitMenu
  355.             endif
  356.             Tmp = '^' + Menus[X].MenuName
  357.          endif
  358.          if (pos('@',Tmp) > 0) And (Pos('@ECHO',UpperCase(Tmp)) = 0)
  359.             X = 1
  360.             while X <= length(Tmp)
  361.                while (X <= length(Tmp)) and (mid(Tmp,X,1) <> '@')
  362.                   X = X + 1
  363.                endwhile
  364.                Z[1] = mid(Tmp,X,1)
  365.                Z[2] = mid(Tmp,X + 1,1)
  366.                if (Z[1] = '@') and (((Z[2] > '0') and (Z[3] <= '9')) or (Z[2] = '"'))
  367.                   if Z[2] = '"'
  368.                      insert(' ',Tmp,X + 1)
  369.                      VarNum = 10
  370.                   else
  371.                      VarNum = ord(Z[2]) - 48
  372.                   endif
  373.                   InputAVar = mid(Tmp,X + 2,1) = '"'
  374.                   if InputAVar
  375.                      Y = X + 3
  376.                      while (mid(Tmp,Y,1) <> '"') and (Y <= length(Tmp))
  377.                         Y = Y + 1
  378.                      endwhile
  379.                      PromptLine = mid(Tmp,X + 3,Y - (X + 3))
  380.                   else
  381.                      Y = X + 1
  382.                   endif
  383.                   delete(Tmp,X,Y - X + 1)
  384.                   insert('%NovVar' + Str(VarNum)  ,Tmp,X)
  385.                   if InputAVar
  386.                      FileWriteln(Out,'   |%NovVar',Str(VarNum), ' = ReadTextLine("' + PromptLine + '","",0,21)')
  387.                   endif
  388.                endif
  389.             endwhile
  390.          endif
  391.          FileWriteln(Out,'   ' + Tmp)
  392.       endloop
  393.       BlankLine
  394.    endloop
  395. EndProc
  396.  
  397. ;----- Create the Menus
  398.  
  399. Procedure WriteOutMenus
  400.   Writeln
  401.   Loop Menus
  402.      MenuPtr = LoopIndex
  403.      Actual ThisMenu = Loc Menus[MenuPtr]
  404.      WriteOutMenuChoices
  405.      WriteOutOnkeyChoices
  406.      if MenuPtr = 1
  407.         FileWriteln(Out,'OnKey ESC')
  408.         FileWriteln(Out,'   |if not KeepUsersInMenu or NovConsoleOperator')
  409.         FileWriteln(Out,'   |   LeaveMenu')
  410.         FileWriteln(Out,'   |endif')
  411.         BlankLine
  412.      endif
  413.   EndLoop
  414. EndProc
  415.